home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 322 / flex / atarist.c next >
Encoding:
C/C++ Source or Header  |  1988-10-20  |  919 b   |  71 lines

  1. /* atari specific stuff */
  2.  
  3. #include <stdio.h>
  4.  
  5. char * def_skel_file()
  6. {
  7.   char * foo = getenv("FLEX_DEF");
  8.  
  9.   if (foo)
  10.     return(foo);
  11.     else
  12.     return("flexdef.skl");
  13. }
  14.  
  15.  
  16. char * fast_skel_file()
  17. {
  18.   char * foo = getenv("FLEX_FAST");
  19.  
  20.   if (foo)
  21.     return(foo);
  22.     else
  23.     return("flexfast.skl");
  24. }
  25.  
  26. int abs(a)
  27. int a;
  28. {
  29.   if (a >= 0)
  30.     return(a);
  31.     else
  32.     return(-a);
  33. }
  34.  
  35. int cr_filtering_read(f, buf, nbytes)
  36. FILE * f;
  37. char * buf;
  38. int nbytes;
  39. {
  40.   char * b = buf;
  41.   int nbytes_read = 0;
  42.   int c;
  43.  
  44.   for ( ; nbytes > 0 ; nbytes--)
  45.     {
  46.     c = fgetc(f);
  47.     if (c == EOF) break;
  48.     if (c != '\r')
  49.         {
  50.         *b++ = c;
  51.         nbytes_read++;
  52.         }
  53.     }
  54.   return (nbytes_read);
  55. }
  56.  
  57. /* should migrate this into lib */
  58. puts(str)
  59. char * str;
  60. {
  61.   char c;
  62.   int eol_flag = 0;
  63.  
  64.   while (c = *str++)
  65.     {
  66.     eol_flag = (c == '\r');
  67.     fputc(c, stdout);
  68.     }
  69.   if (!eol_flag)
  70.     fputc('\n', stdout);
  71. }